package com.smartsoft.model;

/**
 * Serves as a container for contact data during transferring this data
 * between edit and preview pages.
 */
public class ContactData {
    /**
     * Drawable resource Id for avatar (cover flow).
     */
    private final int avatarDrawId;
    private final String name;
    private final String phoneNumber;
    private final String email;
    /**
     * Selected country position in carousel list.
     */
    private final int selectedCountryPosition;

    /**
     * This inner class intended for building instances of ContactData class
     * and implements Builder pattern.
     */
    public static class Builder {
        private int avatarDrawId;
        private String name;
        private String phoneNumber;
        private String email;
        private int selectedCountryPosition;

        public Builder setAvatarDrawableId(int avatarDrawableId) {
            this.avatarDrawId = avatarDrawableId;
            return this;
        }

        public Builder setName(String name) {
            this.name = name;
            return this;
        }

        public Builder setPhoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
            return this;
        }

        public Builder setEmail(String email) {
            this.email = email;
            return this;
        }

        public Builder setSelectedCountryPosition(int selectedCountryPosition) {
            this.selectedCountryPosition = selectedCountryPosition;
            return this;
        }

        public ContactData build() {
            return new ContactData(this);
        }
    }

    protected ContactData(Builder builder) {
        avatarDrawId = builder.avatarDrawId;
        name = builder.name;
        phoneNumber = builder.phoneNumber;
        email = builder.email;
        selectedCountryPosition = builder.selectedCountryPosition;
    }

    /**
     * Return information stored in ContactData instance in
     * convenient, readable way.
     *
     * @return contact data information represented as string object
     */
    @Override
    public String toString() {
        StringBuilder res = new StringBuilder();
        res.append("-----------------------------------").append("\n")
           .append("Avatar drawable Id = ").append(avatarDrawId).append("\n")
           .append("Name = ").append(name).append("\n")
           .append("Phone number = ").append(phoneNumber).append("\n")
           .append("Email = ").append(email).append("\n")
           .append("Selected country position = ").append(selectedCountryPosition).append("\n")
           .append("-----------------------------------");
        return res.toString();
    }


    public int getAvatarPosition() {
        return avatarDrawId;
    }

    public String getName() {
        return name;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public String getEmail() {
        return email;
    }

    public int getSelectedCountryPosition() {
        return selectedCountryPosition;
    }
}
